//
// Created by Incredible on 17/3/22.
//

#ifndef GRAPHTHEORY_ADJITERATORTEST_H
#define GRAPHTHEORY_ADJITERATORTEST_H

#include <iostream>
#include "SparseGraph.h"
#include "DenserGraph.h"

using namespace std;

namespace GraphTestHelper {

    //测试迭代器 稀疏图
    void testAdjIteratorSparseGraph(int v, int w) {
        srand(time(NULL));

        bool directed = false;

        //生成图
        SparseGraph sparseGraph(v,directed);

        //初始化
        for(int i = 0; i<w;i++){

            //随机挑选v对顶点添加边
            int a = rand()%v;
            int b = rand()%v;
            sparseGraph.addEdge(a, b);

        }

        //输出v个结点的临界顶点
        for(int i = 0; i< v;i++){

            cout<<i<<" : ";
            //创建迭代器
            SparseGraph::adjIterator adjIterator(sparseGraph,i);

            for (int j = adjIterator.begin(); !adjIterator.end() ;j = adjIterator.next()) {
                cout<<j<<" ";
            }
            cout<<endl;
        }
    }

    //测试迭代器 稀疏图
    void testAdjIteratorDenserGraph(int v, int w) {
        srand(time(NULL));

        bool directed = false;

        //生成图
        DenserGraph denserGraph(v,directed);

        //初始化
        for(int i = 0; i<w;i++){

            //随机挑选v对顶点添加边
            int a = rand()%v;
            int b = rand()%v;
            denserGraph.addEdge(a, b);

        }

        //输出v个结点的临界顶点
        for(int i = 0; i< v;i++){

            cout<<i<<" : ";
            //创建迭代器
            DenserGraph::adjIterator adjIterator(denserGraph,i);

            for (int j = adjIterator.begin(); !adjIterator.end() ;j = adjIterator.next()) {
                cout<<j<<" ";
            }
            cout<<endl;
        }
    }
}


#endif //GRAPHTHEORY_ADJITERATORTEST_H
